# coding:utf-8
'''
条件 a + b + c = 1000, a^2 + b^2 = c^2 
输出 a,b,c 所有的组合
'''

# 性能最差，算法逻辑最简单
def cls():
    for a in range(1001):
        for b in range(1001):
            for c in range(1001):
                if a + b + c == 1000 and a ** 2 + b ** 2 == c ** 2:
                    print(a,b,c)

# 性能稍好，算法逻辑比较简单
def cls1():
    for a in range(1001):
        for b in range(1001):
            c = 1000 - b -a
            if a ** 2 + b ** 2 == c ** 2:
                print(a,b,c)
# 性能较好，算法逻辑简单
def cls2():
    for a in range(1001):
        for b in range(1001-a):
            c = 1000 -a -b
            if a ** 2 + b ** 2 == c ** 2:
                print(a,b,c)
# 性能最好，算法逻辑有点复杂
def cls3():
    import math
    for a in range(1000):
        if (1000 * 1000 - 2000 * a) % (2000 - 2 * a) == 0 and (1000 * 1000 - 2000 * a) // (2000 - 2 * a) > 0:
            b = (1000 * 1000 - 2000 * a) // (2000 - 2 * a)
            c = int(math.sqrt(a ** 2 + b ** 2))
            print(a,b,c)

def main():
    import time
    start_time = time.time()
    # cls()
    cls2()
    end_time = time.time()
    print("time: ",(end_time - start_time))

    time.sleep(3)
    start_time = time.time()
    # cls()
    cls3()
    end_time = time.time()
    print("time: ", (end_time - start_time))

if __name__ == '__main__':
    main()